package ibmetp.mis.serviceImpl;

import ibmetp.mis.common.Constants;

import ibmetp.mis.dao.DeptDao;
import ibmetp.mis.service.DeptService;
import ibmetp.mis.service.PageService;
import ibmetp.mis.vo.Dept;
import ibmetp.mis.vo.Page;
/**
 * 部门service接口实现
 * @author LIN A ER
 * @created 2011-10-6
 */
public class DeptServiceImpl implements DeptService, PageService {
	private DeptDao dd=new DeptDao();
    /**
     * 新增部门
     */
	public String addDept(Dept dept) {
		// TODO Auto-generated method stub
		//if(dd.getDeptById(dept.getDeptNo()))
		//if(dd.getDeptById(dept.getDeptNo())!=null)//判断新部门是否已存在
		//{
		//	return Constants.DEPT_EXISTS;
		//}
		dd.addDept(dept);
		return null;
	}
    /**
     * 通过部门id删除部门
     */
	public String deleteDeptById(Long id) {
		// TODO Auto-generated method stub
		dd.deleteDeptById(id);
		return null;
	}
    /**
     * 通过部门编号删除部门
     */
	public String deleteDeptByNo(String No) {
		// TODO Auto-generated method stub
		dd.deleteDeptByNo(No);
		return null;
	}
     /**
      * 通过部门id获取部门信息
      */
	public Dept getDeptById(Long id) {
		// TODO Auto-generated method stub
		return dd.getDeptById(id);
	}
	/**
	 * 通过部门编号获取部门信息
	 */
	public Dept getDeptByNo(String No) {
		// TODO Auto-generated method stub
		return dd.getDeptByNo(No);
	}
	/**
	 * 更新部门
	 */
	public String updateDept(Dept dept) {
		// TODO Auto-generated method stub
		Dept d=dd.getDeptById(dept.getDeptId());//首先要判断新增部门是否已存在
		if(d==null)
		{
			return "不存在此部门";
		}
		dd.updateDept(dept);
		return null;
	}
	/**
	 * 实现分页查询部门
	 */
	public Page getPage(int pageNo, int pageSize, Object object) {
		// TODO Auto-generated method stub
		Page page=dd.getUserPage(pageNo, pageSize, object);
		return page;
	}
	public String deleteDeptByIds(String ids) {
		// TODO Auto-generated method stub
		dd.deleteDeptByIds(ids);
		return null;
	}
	/**
	 * 
	 */
	public String setManager(Long deptId, Long mgrId) {
	     dd.setManager(deptId, mgrId);
		return null;
	}

}
